﻿using System;
using System.Diagnostics;
using System.Xml;
using Landpy.LogAnalyzer.Core;

namespace Landpy.LogAnalyzer.Configuration
{
    internal class ConfigurationReader : IConfigurationReader
    {
        private readonly string configurationFileName;

        public ConfigurationReader(string configurationFileName)
        {
            this.configurationFileName = configurationFileName;
        }

        #region IConfigurationReader Members

        public Setting GetSetting()
        {
            Setting logColumnSchema = null;
            try
            {
                var xmlDocument = new XmlDocument();
                xmlDocument.Load(configurationFileName);
                logColumnSchema = SerializeProvider.Deserialize<Setting>(xmlDocument.OuterXml);
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
            }
            return logColumnSchema;
        }

        #endregion
    }
}